function fig1()
%FIG1 Summary of this function goes here
%   Detailed explanation goes here
global f1;      
global hEdit1;        
global hEdit2;
global hEdit3;
global hEdit4;
global hEdit5;
global hEdit6;
global hEdit7;
global hRadio1;
global S_Map;
global D_Map;
global scene_size;
global user_break;
global user_pause;
global hStart;
global hBreak;

delta_x=150;
delta_y=150;

f1 = figure('Visible','on','Position',[725-delta_x,425-delta_y,550+delta_x,285+delta_y], 'ToolBar','figure');

% -------------------------------------------------------------------------
h1 = axes('Units','Pixels','Position',[50,22,435+delta_x,231+delta_y]);
% controls definition
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
hStart = uicontrol('Style','pushbutton','Position',[461+delta_x,228+delta_y,70,25],'String','Pause',...
    'Callback',{@buttonStart_Callback});

%hResume = uicontrol('Style','pushbutton','Position',[461+delta_x,198+delta_y,70,25],'String','Resume',...
%    'Callback',{@buttonResume_Callback});

hPop1 = uicontrol('Style', 'popup','Position', [461+delta_x,160+delta_y,85,25],'String',...
    {'view(45,0)','view(0,60)','view(0,90)'},'Callback',{@popupPop1_Callback});

hBreak = uicontrol('Style','pushbutton','Position',[461+delta_x,22,70,25],'String','Stop',...
    'Callback',{@buttonBreak_Callback});

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
hRadio1 = uicontrol('Style','radio','Position',[200,255+delta_y,90,15],'String','Runnig');
set(hRadio1, 'Enable', 'inactive');

hText1 = uicontrol('Style','text','Position',[50,272+delta_y,52,15],'String','Loop#');
hEdit1 = uicontrol('Style','edit','max',1,'Position',[50,255+delta_y,51,15],'String','1', 'Enable', 'inactive');

hText2 = uicontrol('Style','text','Position',[100,272+delta_y,52,15],'String','TotalE');
hEdit2 = uicontrol('Style','edit','max',1,'Position',[100,+255+delta_y,51,15],'String','0', 'Enable', 'inactive');


hText3 = uicontrol('Style','text','Position',[150,272+delta_y,52,15],'String','#ofMsgs');
hEdit3 = uicontrol('Style','edit','max',1,'Position',[150,255+delta_y,51,15],'String','0', 'Enable', 'inactive');

hText4 = uicontrol('Style','text','Position',[459+delta_x,91,84,15],'String','Avg energy');
hEdit4 = uicontrol('Style','edit','max',1,'Position',[459+delta_x,66,74,25],'String','0', 'Enable', 'inactive');

hEdit5 = uicontrol('Style','edit','Position',[550,270+delta_y,101,15],'String','1', 'Enable', 'inactive');
hEdit6 = uicontrol('Style','edit','max',1,'Position',[650,270+delta_y,51,15],'String','2', 'Enable', 'inactive');

hText7 = uicontrol('Style','text','Position',[459+delta_x,145,84,15],'String','Avg error');
hEdit7 = uicontrol('Style','edit','max',1,'Position',[459+delta_x,120,74,25],'String','0', 'Enable', 'inactive');

% hEdit4 = uicontrol('Style','edit','max',1,'Position',[200,255,51,15],'String','N');
% 
% hText4 =
% uicontrol('Style','text','Position',[200,272,52,15],'String','End');

view(45,0);

fig1_clear();     

set([f1,h1,hStart,hBreak,hRadio1,hEdit1, hText1,hText4,...
    hEdit2, hText2, hEdit3, hText3, hPop1, hEdit4,hEdit5,hEdit6],'Units','normalized');

% --------------------- END OF FIGURE ----------------------
    function popupPop1_Callback(source,eventdata)
        str = get(source, 'String');
        val = get(source,'Value');
        switch str{val};
            case 'view(45,0)'
                view(45,0);
            case 'view(0,60)' 
                view(0,60);
            case 'view(0,90)' 
               % drawnow;
                view(0,90);
        end
    end

    function buttonBreak_Callback(source,eventdata)
        user_break = 1;
        set(hBreak,'String','Stopping');
        uiresume(gcbf);
        %uiresume(gcbf);
    end

    function buttonStart_Callback(source,eventdata)
        if (user_pause)
            user_pause = 0;
            set(hStart,'String','Pause');
            set(hRadio1,'String','Running');
            uiresume(gcbf);
        else
            user_pause = 1;
            set(hStart,'String','Continue');
            set(hRadio1,'String','Paused');
            uiwait(gcf);
        end
    end

%     function buttonResume_Callback(source,eventdata)
%         user_pause = 0;
%         set(hStart,'String','Stopping');
%         uiresume(gcbf);
%     end
%% -----------------------------------------------------------

end

